Skip to content

fix: vessel-switch stale camera reattach + docking camera list#3

Closed
jonpepler wants to merge 4 commits into
mainfrom
fix/vessel-switch-stale-ring-reattach
Closed

fix: vessel-switch stale camera reattach + docking camera list#3
jonpepler wants to merge 4 commits into
mainfrom
fix/vessel-switch-stale-ring-reattach

Conversation

@jonpepler

Copy link
Copy Markdown
Owner

Summary

  • Fixes Issues switching vessels #2 — a camera whose part persists across onVesselChange (e.g. a booster surviving separation, or a docking-port camera reused across dock/undock) could be deleted and recreated at the same flight_id within one tick, with no destroyed tombstone. The sidecar's rescan only reattached rings for tombstoned entries, so the mmap stayed pointed at the unlinked file forever — no browser refresh could recover it. rescan() now tracks each ring's filesystem identity and reattaches whenever it changes, reusing the existing attach-driven peer resync path.
  • Also fixes a related gap found during live testing: docking two vessels never revealed the joined camera list until an unrelated vessel switch happened to fire afterward. RebuildCameraList now takes a disposeMissing flag — onVesselChange keeps full dispose+rebuild (scope to whichever vessel you're flying), onVesselWasModified (docking/staging without a pilot switch) now also calls it additively, picking up a docking partner's cameras immediately without tearing down staged-off debris cameras that should persist until they leave physics range.
  • Expanded docs/TROUBLESHOOTING.md's "Still stuck?" section into a reusable log-collection checklist.

Test plan

  • cargo test (96 tests, including a new regression test reproducing the ring-recreate race) + cargo clippy --all-targets clean on linux/windows/macOS CI
  • Plugin builds clean (0 warnings) against local KSP managed assemblies
  • Live-tested on Steam Deck across booster-separation, vessel-switch, and dock/undock scenarios — confirmed the reattach path engages correctly (ring file identity changed... reattaching / re-attached camera rebound to surviving peer subscriptions) and camera counts are correct in all traced cases

jonpepler added 4 commits July 7, 2026 10:11
…ed tombstone

RebuildCameraList tears down and rebuilds every tracked camera on
onVesselChange, including ones whose part persists across the switch. That
teardown writes no destroyed tombstone (reserved for actual part
destruction), so a ring can be deleted and recreated at the same flight_id
within one frame with rescan() none the wiser - the sidecar kept its mmap
on the unlinked file, and the feed went stale with no way to recover short
of restarting the sidecar (kerbcast#2).

rescan() now tracks each ring's filesystem identity and reattaches when it
changes, reusing the existing attach-driven peer resync path.

Also expand the TROUBLESHOOTING.md "Still stuck?" section into a reusable
log-collection checklist instead of writing bespoke instructions per issue.
MetadataExt::file_index() is gated behind the unstable windows_by_handle
feature (rust-lang/rust#63010) and failed the windows-2022 CI job. Fall back
to the file's mtime in nanoseconds on non-unix instead of pulling in an
unstable API for a tier-2 platform.
The non-unix identity fallback (mtime) can't distinguish two files created
within the same CI-runner tick, which is what the test does deliberately to
force the race. That's a real limit of the tier-2 fallback, not a bug the
test should assert against on windows.
…ssel switch

RebuildCameraList only ever ran from onVesselChange, so docking two vessels
never revealed the joined craft's cameras until an unrelated later vessel
switch happened to fire - confirmed live (kerbcast#2 follow-up): a dock at
12:36:54 with no accompanying switch stayed at the pre-dock camera count,
while a dock immediately followed by a switch correctly showed all cameras.

RebuildCameraList now takes a disposeMissing flag. onVesselChange keeps the
existing full dispose+rebuild (scope the list to whichever vessel you're
flying). onVesselWasModified - which fires on docking/staging without a
pilot switch - now also calls it, but additively only: skip already-tracked
flight IDs, never dispose. This picks up a docking partner's cameras
immediately, without tearing down staged-off debris cameras that should
only stop streaming when they actually leave physics range.
@jonpepler jonpepler closed this Jul 7, 2026
@jonpepler jonpepler deleted the fix/vessel-switch-stale-ring-reattach branch July 7, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues switching vessels

1 participant